﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Sohobloo.SoCommon.Security;

namespace Mojito.Common
{
    public static class OrderNumberObfuscator
    {
        public static string Obfuscate(string originalOrderNumber)
        {
            var datePart = originalOrderNumber.Substring(0, 8);
            var datePartSeed = Convert.ToInt32(datePart);
            var serialPartSeed = Convert.ToInt32(originalOrderNumber.Substring(8));
            var randomDatePart = new Random(datePartSeed).Next(1, 99);
            var randomSerialPart = new Random(serialPartSeed).Next(1, 99);
            var obfuscatedSerial = (randomDatePart * randomSerialPart - 1).ToString("D4");
            return datePart + obfuscatedSerial;
        }
    }
}
